package com;


import com.lin.entity.Font;
import com.lin.execute.FontUtil;
import com.lin.execute.PropUtil;
import com.lin.execute.ScreenUtil;
import com.lin.info.PropInfo;
import com.lin.info.PropInfoList;
import com.lin.info.ScreenInfo;

import java.util.List;

public class Main {
    public static final String TYPE_FONT = "font";
    public static final String TYPE_SCENE = "scene";
    public static final String TYPE_PROP = "prop";

    public static final String PATH_FONT  = "D:\\OneDrive\\桌面\\test\\npcfonts.xml";
    public static final String PATH_SCENE  = "";
    public static final String PATH_Prop  = "";

    public static void main(String[] args) {
        run(TYPE_FONT,PATH_FONT);
    }

    public static void run(String type,String path) {
        switch (type) {
            case TYPE_FONT:
                runFontProcessing(path);
                break;
            case TYPE_SCENE:
                runSceneProcessing(path);
                break;
            case TYPE_PROP:
                runPropProcessing(path);
                break;
            default:
                System.out.println("无效的选择！");
        }

    }

    // 执行字体处理逻辑
    private static void runFontProcessing(String path) {
        List<Font> fonts = FontUtil.getFontList(path);
        for (Font font : fonts) {
            font.setFontTypeId(2L);
            FontUtil.save(font);
        }
    }

    // 执行场景处理逻辑
    private static void runSceneProcessing(String path) {
        ScreenInfo sceneData = ScreenUtil.parseXmlFile(path);
        ScreenUtil.saveScreen(sceneData.getScene());
        ScreenUtil.saveNPC(sceneData.getNpc());
        ScreenUtil.saveScenario(sceneData.getRoomList());
        ScreenUtil.saveWaypoint(sceneData.getWaypointList());
    }

    // 执行道具处理逻辑
    private static void runPropProcessing(String path) {
        PropInfoList propInfoList = PropUtil.propInfoList(path);
        System.out.println(propInfoList);

        for (PropInfo propInfo : propInfoList.getPropInfoList()) {
//            PropApp.save(propInfo.getMatrix());  // 如果需要保存就取消注释
            System.out.println(propInfo.getProp().toString());
        }
    }
}
